<template>
  <el-form ref="searchForm" :model="searchForm" label-width="120px">
    <el-row v-if="conditionCount > 0">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="用户手机号" prop="userPhone" label-for="userPhone">
          <el-input
            v-model="searchForm.userPhone"
            element-id="userPhone"
            placeholder="请输入用户手机号"
            clearable
            @keyup.enter.native="handleSubmit"
          />
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="用户昵称" prop="userNickname" label-for="userNickname">
          <el-input
            v-model="searchForm.userNickname"
            element-id="userNickname"
            placeholder="请输入用户昵称"
            clearable
            @keyup.enter.native="handleSubmit"
          />
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="提现方式" prop="withdrawType">
          <el-select
            v-model="searchForm.withdrawType"
            placeholder="请选择提现方式"
            clearable
            style="width: 100%;"
            @change="handleSubmit"
          >
            <el-option
              v-for="item in selects.withdrawTypeSelect"
              :value="item.value"
              :key="item.value"
              :label="item.displayValue"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-button
          type="primary"
          style="margin-left: 10px;"
          :loading="loading.search"
          @click="handleSubmit"
        >搜索</el-button>
        <el-button @click="handleReset">重置</el-button>
        <a v-if="conditionCount > 3" style="margin-left: 10px;" @click="collapse = !collapse">
          <el-button type="text" v-if="!collapse">
            展开
            <svg-icon icon-class="ios-arrow-down" />
          </el-button>
          <el-button v-else type="text">
            收起
            <svg-icon icon-class="ios-arrow-up" />
          </el-button>
        </a>
      </el-col>
    </el-row>
    <el-row v-if="collapse">
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="发起提现的应用" prop="withdrawClientApp">
          <el-select
            v-model="searchForm.withdrawClientApp"
            placeholder="请选择发起提现的应用"
            clearable
            style="width: 100%;"
            @change="handleSubmit"
          >
            <el-option
              v-for="item in selects.withdrawClientAppSelect"
              :value="item.value"
              :key="item.value"
              :label="item.displayValue"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="银行名称" prop="bankName" label-for="bankName">
          <el-input
            v-model="searchForm.bankName"
            element-id="bankName"
            placeholder="请输入银行名称"
            clearable
            @keyup.enter.native="handleSubmit"
          />
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="提现状态" prop="withdrawStatus">
          <el-select
            v-model="searchForm.withdrawStatus"
            placeholder="请选择提现状态"
            clearable
            style="width: 100%;"
            @change="handleSubmit"
          >
            <el-option
              v-for="item in selects.withdrawStatusSelect"
              :value="item.value"
              :key="item.value"
              :label="item.displayValue"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="内部单号" prop="orderNo" label-for="orderNo">
          <el-input
            v-model="searchForm.orderNo"
            element-id="orderNo"
            placeholder="请输入内部单号"
            clearable
            @keyup.enter.native="handleSubmit"
          />
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="外部交易号" prop="transactionNo" label-for="transactionNo">
          <el-input
            v-model="searchForm.transactionNo"
            element-id="transactionNo"
            placeholder="请输入外部交易号"
            clearable
            @keyup.enter.native="handleSubmit"
          />
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="审核时间">
          <el-row>
            <el-col :span="11">
              <el-form-item prop="checkedTimeMin">
                <el-date-picker
                  type="datetime"
                  v-model="searchForm.checkedTimeMin"
                  placeholder="请输入开始审核时间"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%;"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="2" style="text-align: center">-</el-col>
            <el-col :span="11">
              <el-form-item prop="checkedTimeMax">
                <el-date-picker
                  type="datetime"
                  v-model="searchForm.checkedTimeMax"
                  placeholder="请输入结束审核时间"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%;"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form-item>
      </el-col>
      <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
        <el-form-item label="完成时间">
          <el-row>
            <el-col :span="11">
              <el-form-item prop="completeTimeMin">
                <el-date-picker
                  type="datetime"
                  v-model="searchForm.completeTimeMin"
                  placeholder="请输入开始完成时间"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%;"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="2" style="text-align: center">-</el-col>
            <el-col :span="11">
              <el-form-item prop="completeTimeMax">
                <el-date-picker
                  type="datetime"
                  v-model="searchForm.completeTimeMax"
                  placeholder="请输入结束完成时间"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  style="width: 100%;"
                  clearable
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
import * as utils from '@/utils/utils'
import * as ResponseStatus from '@/utils/response-status'
export default {
  name: 'FundsWithdrawSearchQuick',
  data() {
    return {
      loading: {
        search: false,
      },
      conditionCount: 10,
      collapse: false,
      searchForm: {
        pageNo: 1,
        pageSize: 10,
        sortColumn: undefined,
        sortOrder: undefined,
        id: undefined,
        idMin: undefined,
        idMax: undefined,
        userId: undefined,
        userIdMin: undefined,
        userIdMax: undefined,
        userPhone: undefined,
        userNickname: undefined,
        userIsActive: undefined,
        userIsActiveMin: undefined,
        userIsActiveMax: undefined,
        orderNo: undefined,
        transactionNo: undefined,
        withdrawType: undefined,
        withdrawTypeMin: undefined,
        withdrawTypeMax: undefined,
        withdrawClientApp: undefined,
        withdrawClientAppMin: undefined,
        withdrawClientAppMax: undefined,
        amount: undefined,
        amountMin: undefined,
        amountMax: undefined,
        bankcardId: undefined,
        bankcardIdMin: undefined,
        bankcardIdMax: undefined,
        bankName: undefined,
        bankcardNo: undefined,
        withdrawStatus: undefined,
        withdrawStatusMin: undefined,
        withdrawStatusMax: undefined,
        withdrawDescription: undefined,
        checkedUserId: undefined,
        checkedUserIdMin: undefined,
        checkedUserIdMax: undefined,
        checkedUserPhone: undefined,
        checkedUserNickname: undefined,
        checkedUserIsActive: undefined,
        checkedUserIsActiveMin: undefined,
        checkedUserIsActiveMax: undefined,
        checkedTime: undefined,
        checkedTimeMin: undefined,
        checkedTimeMax: undefined,
        completeTime: undefined,
        completeTimeMin: undefined,
        completeTimeMax: undefined,
        version: undefined,
        versionMin: undefined,
        versionMax: undefined,
        createTime: undefined,
        createTimeMin: undefined,
        createTimeMax: undefined,
        updateTime: undefined,
        updateTimeMin: undefined,
        updateTimeMax: undefined,
        isActive: undefined,
        isActiveMin: undefined,
        isActiveMax: undefined,
      },
      dataDictCodes: [
        'YES_NO',
        'WITHDRAW_TYPE',
        'CLIENT_APP',
        'FUNDS_WITHDRAW_STATUS',
      ],
      selects: {
        userIsActiveSelect: [],
        withdrawTypeSelect: [],
        withdrawClientAppSelect: [],
        withdrawStatusSelect: [],
        checkedUserIsActiveSelect: [],
        isActiveSelect: [],
      },
    }
  },
  computed: {},
  mounted() {
    this.initDataDict()
  },
  methods: {
    initDataDict() {
      utils
        .getDataDict(this.dataDictCodes)
        .then((response) => {
          if (response) {
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'YES_NO',
              formProp: 'userIsActive',
              dataProp: 'userIsActiveSelect',
            })
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'WITHDRAW_TYPE',
              formProp: 'withdrawType',
              dataProp: 'withdrawTypeSelect',
            })
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'CLIENT_APP',
              formProp: 'withdrawClientApp',
              dataProp: 'withdrawClientAppSelect',
            })
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'FUNDS_WITHDRAW_STATUS',
              formProp: 'withdrawStatus',
              dataProp: 'withdrawStatusSelect',
            })
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'YES_NO',
              formProp: 'checkedUserIsActive',
              dataProp: 'checkedUserIsActiveSelect',
            })
            utils.getSelectDictItems({
              mainComponent: this,
              dataDictItems: response,
              dictCode: 'YES_NO',
              formProp: 'isActive',
              dataProp: 'isActiveSelect',
            })
          }
        })
        .catch((error) => {
          console.log(error)
        })
    },
    resetForm(excludeProps) {
      for (let key in this.searchForm) {
        if (excludeProps && excludeProps.includes(key)) {
          continue
        }
        this.searchForm[key] = undefined
      }
    },
    handleSubmit() {
      this.$emit('quickSearch')
    },
    handleReset() {
      this.$emit('researchTable')
    },
  },
}
</script>
<style>
.ivu-quick-opt {
  text-align: right;
}
</style>